////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                            //
//                                                         WNProject                                                          //
//                                                                                                                            //
//            This file is distributed under the BSD 2-Clause open source license. See License.txt for details.               //
//                                                                                                                            //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef __WN_IDENTIFIER_MAP_H__
#define __WN_IDENTIFIER_MAP_H__

#include "WNCore/inc/WNBase.h"
#include "WNCore/inc/WNFunctions.h"
#include "WNConcurrency/inc/WNCriticalSection.h"
#include "WNScripting/inc/WNScriptingConfig.h"
#include "WNScripting/inc/WNIdentifierElement.h"

#include <string>
const WNIdentifierElement WNInvalidIdentifier = WN_NULL;

template <>
__WN_INLINE WN_BOOL WNIsValid(WNIdentifierElement _value) {
    return(_value != WNInvalidIdentifier);
}

class WNIdentifierMap {
public:
    WNIdentifierMap();
    ~WNIdentifierMap();
    WNIdentifierElement GetIdentifier(const WN_CHAR * _identifier, WN_SIZE_T _length);
    const WN_CHAR* GetStringFromIdentifier(WNIdentifierElement _element) const;

private:
    WN_UNORDERED_MAP<std::string, char*> mIdentMap;
    WNIdentifierElement mCurValue;

    #ifdef WN_SCRIPTING_MULTITHREADED_PARSING
        WN_CRITICAL_SECTION_T mIdentifierLock;
    #endif
};

#endif // __WN_IDENTIFIER_MAP_H__